package com.hxzy.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.order.entity.TtWaybill;
import com.hxzy.order.entity.vo.WaybillVo;
import com.hxzy.order.mapper.TtWaybillMapper;
import com.hxzy.order.service.TtWaybillService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mingqian.Wu
 * @since 2023-06-27
 */
@Service
@DataSource(DataSourceType.ORDER)
public class TtWaybillServiceImpl extends ServiceImpl<TtWaybillMapper, TtWaybill> implements TtWaybillService {

    @Override
    public Long getCountByStatus(String id, Integer status) {
        QueryWrapper<TtWaybill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("source_id", id);
        queryWrapper.eq("waybill_status", status);
        Long aLong = baseMapper.selectCount(queryWrapper);
        return aLong;
    }


    @Override
    public Long getPaymentStatusCount(String id, Integer status) {
        QueryWrapper<TtWaybill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("source_id", id);
        queryWrapper.eq("payment_status", status);
        Long aLong = baseMapper.selectCount(queryWrapper);
        return aLong;
    }

    @Override
    public List<TtWaybill> searchWaybill(TtWaybill ttWaybill) {
        QueryWrapper<TtWaybill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(Objects.nonNull(ttWaybill.getSourceId()), "source_id", ttWaybill.getSourceId());
        queryWrapper.eq(Objects.nonNull(ttWaybill.getBillOfLadingId()), "bill_of_lading_id", ttWaybill.getBillOfLadingId());
        queryWrapper.eq(Objects.nonNull(ttWaybill.getLicensePlateNumber()), "car_id", ttWaybill.getLicensePlateNumber());
        queryWrapper.like(Objects.nonNull(ttWaybill.getNameOfGood()), "name_of_good", ttWaybill.getNameOfGood());
        List<TtWaybill> ttWaybills = baseMapper.selectList(queryWrapper);
        return ttWaybills;
    }


}
